package tagImage;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.*;

public class TagImage implements ImageObserver {
	private Image image;
	
	public TagImage(String filename)
	{
		try {
			this.image = javax.imageio.ImageIO.read(new File(filename));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		BufferedImage img = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_RGB);
		Graphics g2d = image.getGraphics();
		g2d.setFont(new Font("Serif",Font.PLAIN,12));
		g2d.setColor(Color.WHITE);
		int largeur = image.getWidth(this);
		int hauteur = image.getHeight(this);
		g2d.drawString("HelloWord",largeur / 2, hauteur);
		g2d.drawImage(img, 0, 0, this);
		try {
			javax.imageio.ImageIO.write((RenderedImage) g2d, "JPG", new File("foo.jpg"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		g2d.dispose();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		RechercheFichier file = new RechercheFichier();
		ArrayList<String> ImgContent = file.getFileList();
		new TagImage(ImgContent.get(0));
	}
	@Override
	public boolean imageUpdate(Image arg0, int arg1, int arg2, int arg3,
			int arg4, int arg5) {
		// TODO Auto-generated method stub
		return false;
	}

}
